Skip to content

fix: use content-length header to avoid buffering responses (#711)#714

Closed
stedfn wants to merge 1 commit intogarrytan:mainfrom
stedfn:stedfn/fix-response-size-perf
Closed

fix: use content-length header to avoid buffering responses (#711)#714
stedfn wants to merge 1 commit intogarrytan:mainfrom
stedfn:stedfn/fix-response-size-perf

Conversation

@stedfn
Copy link
Copy Markdown
Contributor

@stedfn stedfn commented Mar 31, 2026

Summary

  • requestfinished handler now reads the content-length header first
  • Only falls back to res.body() when the header is absent
  • Avoids buffering entire response bodies (images, videos, large payloads) just to record byte length

Fixes #711

Test plan

  • bun test passes
  • bun run build succeeds
  • Network buffer still records accurate sizes for responses with content-length header
  • Responses without content-length header still get their size recorded via body fallback

🤖 Generated with Claude Code

garrytan#711)

Check the content-length header first before falling back to res.body().
Avoids buffering entire responses (images, videos, large payloads) just
to record byte length in the network buffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@garrytan
Copy link
Copy Markdown
Owner

garrytan commented Apr 5, 2026

Closing — overlaps with #746 which addresses the same issue. Thank you for the contribution!

@garrytan garrytan closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: res.body() buffers entire response for size calculation

2 participants